//
//  LoginView.m
//  TJHYHardwareProduct
//
//  Created by Kendama on 2018/1/22.
//  Copyright © 2018年 Kendama. All rights reserved.
//

#import "LoginView.h"
#import "PhoneTextFieldView.h"
#import "PasswordTextFieldView.h"

@implementation LoginView

- (UIImageView *)iconImageView
{
    if(!_iconImageView)
    {
        UIView *superView = self;
        _iconImageView = [[UIImageView alloc]init];
        [superView addSubview:_iconImageView];
        _iconImageView.image = [UIImage imageNamed:@"logo"];
    }
    return _iconImageView;
}
- (PhoneTextFieldView *)phoneView
{
    if(!_phoneView)
    {
        UIView *superView = self;
        _phoneView = [[PhoneTextFieldView alloc]init];
        _phoneView.iconImageView.image = imageWithName(@"icon_phone");
        _phoneView.layer.cornerRadius = px1920Height(136)/2;
        _phoneView.backgroundColor = [UIColor colorWithHexString:@"F9F9F9"];
        _phoneView.phoneTextField.placeholder = @"请输入用户名";
        _phoneView.line.hidden = YES;
        [superView addSubview:_phoneView];
    }
    return _phoneView;
}
- (PasswordTextFieldView *)passwordView
{
    if(!_passwordView)
    {
        UIView *superView = self;
        _passwordView = [[PasswordTextFieldView alloc]init];
        _passwordView.iconImageView.image = imageWithName(@"icon_code");
        _passwordView.layer.cornerRadius = px1920Height(136)/2;
        _passwordView.backgroundColor = [UIColor colorWithHexString:@"F9F9F9"];
        _passwordView.passwordTextField.placeholder = @"请输入密码";
        _passwordView.line.hidden = YES;
        [superView addSubview:_passwordView];
    }
    return _passwordView;
}
- (UIButton *)loginButton
{
    if(!_loginButton)
    {
        UIView *superView = self;
        _loginButton = [[UIButton alloc]init];
        [superView addSubview:_loginButton];
        [_loginButton setTitle:@"登录" forState:UIControlStateNormal];
        [_loginButton.titleLabel setFont:fontWithSize(15)];
        [_loginButton setBackgroundImage:[UIImage imageNamed:@"button_login_nor"] forState:UIControlStateNormal];
    }
    return _loginButton;
}

- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    CGFloat edge = px1080Width(67);
    
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(274));
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.height.width.mas_equalTo(px1920Height(300));
    }];
    
    [self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_iconImageView.mas_bottom).with.offset(px1920Height(160));
        make.left.mas_equalTo(superView.mas_left).with.offset(edge);
        make.right.mas_equalTo(superView.mas_right).with.offset(-edge);
        make.height.mas_equalTo(px1920Height(136));
    }];
    
    [self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_phoneView.mas_bottom).with.offset(px1920Height(50));
        make.left.right.height.mas_equalTo(_phoneView);
    }];
    
    [self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_passwordView.mas_bottom).with.offset(px1920Height(50));
        make.left.right.height.mas_equalTo(_phoneView);
    }];
    
    
}

@end
